'''------------------------------------------------------------------------------------------------
 $ @Author: your name
 $ @Date: 2021-12-23 19:04:44
$ @LastEditTime: 2022-03-03 17:32:07
$ @LastEditors: your name
 $ @Description: 在 OTB 上使用 ToolBox
 $ @FilePath: \YSQTrackerEvaluationToolKit_v1.0\RunEval_OTB.py
--------------------------------------------------------------------------------------------------'''
import argparse
from ast import arg
from EvalToolKit.evalToolKit import EvalToolKit

def get_argparse():
    parser = argparse.ArgumentParser(description='-----')
    parser.add_argument(
        '-v',
        '-visual',
        default=False,
        type=bool,
        help = '是否输出跟踪器的可视化跟踪结果'
    )
    return parser.parse_args()


def run():
    '''-------------------------------------------------------------------------------------------
     * @description: 运行evalToolKit工具箱
                    -> 运行 python RunEval_OTB.py -ovrf 'N'       不进行跟踪结果可视化
                    -> 运行 python RunEval_OTB.py -ovrf 'imgFile' 以图像集合方式出书跟踪结果可视化
                    -> 运行 python RunEval_OTB.py -ovrf 'video'   以视频方式出书跟踪结果可视化
                    -> 运行 python RunEval_OTB.py -ovrf 'B'       同时输出imgFile、video
     * @return {*}
    ---------------------------------------------------------------------------------------------'''
    param = get_argparse()
    exp = EvalToolKit()
    exp.init()
    exp.testPerformance()
    exp.analyze()
    if param.visual:
        exp.outputVisualizationResults()
    exp.outputLog()


def eval_tracker(tracker_anno_dir:dir = None, output_dir:str = 'OutPut', useBbox:list = ['all'],outputVisualizationResults = False):
    '''-------------------------------------------------------------------------------------------
     * @description: EvalToolKit工具箱的外置API接口,此函数可以将工具箱嵌入到任意一个代码中
     * @param {dir} tracker_anno_dir = None
                        -> {'trackerName' : 'dir'}
                        -> 一个字典存储跟踪器名与跟踪器bbox的键值对
     * @param {str} output_dir = None
                        -> 评估结果输出的根目录
     * @param {dict} useBbox = None
     * @param {*} outputVisualizationResults = False
     * @return {*}
    ---------------------------------------------------------------------------------------------'''
    exp = EvalToolKit(tracker_anno_dir=tracker_anno_dir,output_dir=output_dir,useBbox=useBbox)
    exp.init()
    exp.testPerformance()
    exp.analyze()
    if outputVisualizationResults:
        exp.outputVisualizationResults()
    exp.outputLog()
if __name__ == "__main__":
    #run()
    a = {'PF_STATE_PRE':r'D:\ExpData\pf_predict_v1'}
    # eval_tracker(a)
    # eval_tracker(a,useBbox = [])
    eval_tracker(a,useBbox = ['C-COT'])